package com.dmcb.common.business.services;

import com.dmcb.common.web.conversion.JsonResult;

/**
 * 基础服务类
 * Created by long on 2016/3/16.
 */
public class BaseService {

    /**
     * 失败场景输出json
     */
    protected JsonResult error(String msg) {
        JsonResult result = new JsonResult();
        result.setStatus(JsonResult.STATUS_ERROR);
        result.setMsg(msg);
        return result;
    }

    /**
     * 警告场景输出json
     */
    protected JsonResult warn(Object obj, String msg) {
        JsonResult result = new JsonResult();
        result.setStatus(JsonResult.STATUS_WARN);
        result.setMsg(msg);
        result.setData(obj);
        return result;
    }

    /**
     * 成功场景输出json
     */
    protected JsonResult success() {
        return success(null);
    }

    /**
     * 成功场景输出json
     */
    protected JsonResult success(Object obj) {
        JsonResult result = new JsonResult();
        result.setStatus(JsonResult.STATUS_SUCCESS);
        result.setData(obj);
        return result;
    }

}
